package com.hlhj.carview.adapter

import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hlhj.carview.R
import com.hlhj.carview.bean.EquipmentDetailBean

/**
 * Created by Never Fear   on 2018\12\21 0021.
Never More....
 */
class EquipmentDetailListAdp(private val datas:ArrayList<EquipmentDetailBean.InfoBean.RepairBean>)
    :BaseQuickAdapter<EquipmentDetailBean.InfoBean.RepairBean,BaseViewHolder>(R.layout.equipment_detail_item,datas) {
    override fun convert(helper: BaseViewHolder?, item: EquipmentDetailBean.InfoBean.RepairBean?) {
        val ov = helper?.getView<View>(R.id.ov)

        when(item?.status_type){
            1->{
                helper?.setText(R.id.tvStatus,"申报成功   ${item?.add_time}")
                helper?.setText(R.id.tvContent,"申报人：${item?.proposer}\n电话：${item?.proposer_phone}\n微信：${item?.wechat}\n保修原因：${item?.cause}")

            }
            2->{
                helper?.setText(R.id.tvStatus,"提取设备   ${item?.add_time}")
                helper?.setText(R.id.tvContent,"提取人：${item?.operator}\n电话：${item?.operator_phone}")
            }
            3->{
                helper?.setText(R.id.tvStatus,"返厂维修   ${item?.add_time}")
                helper?.setText(R.id.tvContent,"您的设备正在返厂维修中，请耐心等待！")
            }
            4->{
                helper?.setText(R.id.tvStatus,"维修完成   ${item?.add_time}")
                helper?.setText(R.id.tvContent,"您的设备已经完成维修")
            }
        }

        when(helper?.adapterPosition){
            0->{
                val drawable = ov?.background as GradientDrawable
                drawable.setColor(Color.parseColor("#FFFE475C"))
                helper?.setAlpha(R.id.tvStatus,1f)
                helper?.setAlpha(R.id.tvContent,1f)
            }
            1->{
                val drawable = ov?.background as GradientDrawable
                drawable.setColor(Color.parseColor("#FF1C3453"))
                helper?.setAlpha(R.id.tvStatus,0.3f)
                helper?.setAlpha(R.id.tvContent,0.3f)
            }
            2->{
                val drawable = ov?.background as GradientDrawable
                drawable.setColor(Color.parseColor("#FF1C3453"))
                helper?.setAlpha(R.id.tvStatus,0.3f)
                helper?.setAlpha(R.id.tvContent,0.3f)
            }
            3->{
                val drawable = ov?.background as GradientDrawable
                drawable.setColor(Color.parseColor("#FF1C3453"))
                helper?.setAlpha(R.id.tvStatus,0.3f)
                helper?.setAlpha(R.id.tvContent,0.3f)
            }

        }
    }
}